<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<?php $real_name = $real_name?$real_name:"该";?>
<div class="subnav">
	<div class="content-menu ib-a blue line-x">
		<span style="color:black;font-weight:bolder;font-size:20px;"><?php echo $real_name.'选手：关联图片信息'?></span>
		<a href="./index.php?m=pass_game&c=manage&a=pass_talent&pass_id=<?php echo $pass_id;?>" ><em style="color:blue;font-weight:bolder;">返回上一级</em></a>
	</div>
</div>
<div class="pad-lr-10">

	<div id="searchid" style="">
			<input type="hidden" value="<?php echo ROUTE_M;?>" name="m">
			<input type="hidden" value="<?php echo ROUTE_C;?>" name="c">
			<input type="hidden" value="<?php echo ROUTE_A;?>" name="a">
			<input type="hidden" value="<?php echo $source_type;?>" name="source_type">
			<input type="hidden" value="1" name="search">
			<input type="hidden" value="<?=$pass_id?>" name="pass_id">
			<input type="hidden" value="<?=$real_name?>" name=name>
			<input type="hidden" value="<?php echo $pc_hash;?>" name="pc_hash">
			<table width="100%" cellspacing="0" class="search-form">
				<tbody>
				<tr>
					<td>
					    <form name="myform2" id="form2" action="?m=pass_game&c=talent&a=add_talent_pic&talent_id=<?php echo $talent_id;?>&real_name=<?php echo $real_name?>" method="post">
					       <b>添加选手图片：</b><?php echo form::images('data[pic_url]', 'pic_url','', 'pass_game', '', 40)?><br/>
					       <input type="hidden" name="data[talent_id]" value="<?php echo $talent_id?>">
					       <input type="submit" name="submit2" value="<?php echo L('submit')?>" class="button">
		                </form>
						<button type="button" style="float:right;margin-right:30px;margin-top:10px;border-radius:5px;background:none;" onclick="showSelect()" ><span style="color:red;font-size:15px;">选择图片</span></button>
						<script>
							function  showSelect(){
								window.top.art.dialog({
										id: 'select',
										iframe: '?m=pass_game&c=talent&a=bindTalentPic&talent_id=<?=$talent_id?>&real_name=<?php echo $real_name;?>',
										title: '<?php echo $real_name."";?>选手：绑定图片',
										width: '900',
										height: '500',
										lock: true
									},
									function() {
										var d = window.top.art.dialog({
											id: 'select'
										}).data.iframe;
										var relation = d.document.getElementById('relation');


										if(relation.value!=""){
											$.ajax({
												type:"get",
												url:"?m=pass_game&c=talent&a=bindPicAjax&talent_id=<?=$talent_id?>&relation="+relation.value+"&pc_hash=<?php echo $_SESSION['pc_hash'];?>&pass_id=<?php echo $pass_id;?>&real_name=<?php echo $real_name;?>",
												dataType: "json",
												success:function(data){
													if(data['status']){
														window.top.art.dialog({
															id: 'select'
														}).close()
														window.location.reload();
													}else{
														alert(data['msg']);
														return false;
													}
												}
											})
										}else{
											return true;
										}

									},
									function() {
										window.top.art.dialog({
											id: 'select'
										}).close()
									});
							}
						</script>
					</td>
				</tr>
				</tbody>
			</table>
	</div>

	<form name="myform" id="myform" action="" method="post" >
		<div class="table-list">
			<table width="100%">
				<thead>
				<tr>
					<th width="16"><input type="checkbox" value="" id="check_box" onclick="selectall('id[]');"></th>
					<th width="40">ID</th>
					<th>图片</th>
					<th>绑定时间</th>
					<th>绑定者</th>
					<th width="200"><?php echo L('operations_manage');?></th>
				</tr>
				</thead>
				<tbody>
				<?php
				if(!empty($pics_ids)) {
					foreach ($pics_ids as $k=> $r) {
						?>
						<tr>
							<td align="center"><input class="inputcheckbox " name="id[]" value="<?php echo $r['id'];?>" type="checkbox"></td>
							<td align="center"><?php echo $r['id'];?></td>
							<td align='center'><?php if(!empty($r['pic_url'])){echo '<img src="'.$r['pic_url'].'" width="100px">';}else{echo '<font color="red">（未设置）</font>';}?></td>
							<td align="center"><?php echo $r['create_time'];?></td>
							<td align="center"><?php echo $administrators[$r['created_by']];?></td>
							<td align='center'><a href="?m=pass_game&c=talent&a=delete_pic&id=<?php echo $r['id']?>&pic_url=<?php echo $r['pic_url'];?>&talent_id=<?php echo $talent_id;?>&real_name=<?php echo $real_name;?>" onClick="return confirm('<?php echo L('confirm', array('message' => new_addslashes($r['real_name'])))?>')"><?php echo L('deletebind')?></a></td>

						</tr>
					<?php }
				} else {
					echo "<tr><td colspan='6' style='color:red;font-size:18px;text-align:center;'><span>暂无".$real_name."的相关图片数据，请点击右上角[选择图片]！</span></td></tr>";
				}
				?>
				</tbody>
			</table>
			<div class="btn"><label for="check_box"><?php echo L('selected_all');?>/<?php echo L('cancel');?></label>
				<input type="hidden" value="<?php echo $pc_hash;?>" name="pc_hash">
				<input type="button" class="button" value="<?php echo L('deletebind');?>" onclick="myform.action='?m=pass_game&c=talent&a=delete_pic&dosubmit=1&talent_id=<?php echo $talent_id;?>&real_name=<?php echo $real_name;?>';return confirm_delete()"/>
			</div>
			<div id="pages"><?php echo $pages;?></div>
		</div>
	</form>
</div>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>cookie.js"></script>
<script type="text/javascript">

	function confirm_delete(){
		if(confirm('<?php echo L('confirm');?>')) $('#myform').submit();
	}
</script>
</body>
</html>